package com.foreveross.fetl.core.domain.task.repository.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.foreveross.fetl.common.jpa.EntityOracleHibernateRepository;
import com.foreveross.fetl.core.domain.task.UserCareLineEntity;
import com.foreveross.fetl.core.domain.task.repository.UserCareLineEntityRepository;

@Repository("userCareLineEntityRepository")
public class UserCareLineEntityRepositoryImpl extends
		EntityOracleHibernateRepository implements UserCareLineEntityRepository {

	@Override
	public List<UserCareLineEntity> findUserCareLines() {
		List<UserCareLineEntity> list = this.findAll();
		List<UserCareLineEntity> lines =new ArrayList<UserCareLineEntity>();
		Map<String,String> map= new HashMap<String,String>();
		if(null!=list){
			for(UserCareLineEntity entity: list){
				String key =entity.getDepartCityCode()+entity.getArrivalCityCode();
				if(map.get(key)!=null){
					continue;
				}
				lines.add(entity);
				map.put(key, key);
			}
		}
		return lines;
	}

	@Override
	public List<UserCareLineEntity> findAll() {
		return super.findAll(UserCareLineEntity.class);
	}

}
